# This is a sample Python script.
import numpy as np
from IPython import display
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.


if __name__ == '__main__':
    # 1.分别随机生成六个班的考试成绩，每个班50人，考试共三门：Python、数学、语文。每个班级成绩的shape应当是50x3
    c1 = np.random.randint(0, 101, size=(50,3))
    c2 = np.random.randint(0, 101, size=(50, 3))
    c3 = np.random.randint(0, 101, size=(50, 3))
    c4 = np.random.randint(0, 101, size=(50, 3))
    c5 = np.random.randint(0, 101, size=(50, 3))
    c6 = np.random.randint(0, 101, size=(50, 3))

    # 2.将这六个班的考试成绩垂直叠加得到二维数组score。(即score的每一行是一个同学的成绩)
    scores = np.vstack((c1,c2,c3,c4,c5,c6))
    print('scores:\n', scores)

    # 3.生成性别数组sex，水平叠加数组sex和score得到data
    sex = np.random.randint(0,2, size=(300, 1))
    # print('sex:\n', sex)
    data = np.hstack((scores, sex))
    print('data:\n', data)

    # 4.分性别计算各科成绩的统计指标：最小值、最大值、平均分、中位数、标准差
    # max = np.argmax(data.where(), axis=0)
    # print('max:\n', max)
    cond = data[:,3] == 0
    data_min = data[cond].min(axis=0)  # 女生各科最小值
    data_max = data[cond].max(axis=0)  # 女生各科最大值
    data_mean = data[cond].mean(axis=0)  # 女生各科平均分
    data_median = np.median(data[cond], axis=0)  # 女生各科中位数
    data_std = np.std(data[cond], axis=0)  # 女生各科标准差

    con1 = data[:,3] == 1
    data_min = data[con1].min(axis = 0) # 男生各科最小值
    data_max = data[con1].max(axis = 0) # 男生各科最大值
    data_mean = data[con1].mean(axis = 0) # 男生各科平均分
    data_median = np.median(data[con1],axis=0) # 男生各科中位数
    data_std = np.std(data[con1],axis=0) # 男生各科标准差


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
